package com.bytedance.retrofit2.mime;

import android.text.TextUtils;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;

public class TypedByteArray implements TypedInput, TypedOutput {
    public final byte[] bytes;
    private final String mimeType;

    public TypedByteArray(String mimeType, byte[] bytes) {
        if (mimeType == null) {
            mimeType = TextUtils.isEmpty(null) ? "application/unknown" : "application/octet-stream";
        }
        if (bytes == null) {
            throw new NullPointerException("bytes");
        }
        this.mimeType = mimeType;
        this.bytes = bytes;
    }

    public final String mimeType() {
        return this.mimeType;
    }

    public final void writeTo(OutputStream out) throws IOException {
        out.write(this.bytes);
    }

    public final InputStream in() throws IOException {
        return new ByteArrayInputStream(this.bytes);
    }

    public final long length() {
        return ((long) this.bytes.length);
    }

    public final String fileName() {
        TextUtils.isEmpty(null);
        return null;
    }

    public boolean equals(Object obj) {
        boolean v0 = true;
        if (this != obj) {
            if (obj != null && this.getClass() == obj.getClass()) {
                if (!Arrays.equals(this.bytes, ((TypedByteArray) obj).bytes)) {
                    v0 = false;
                } else if (!this.mimeType.equals(((TypedByteArray) obj).mimeType)) {
                    v0 = false;
                } else {
                }
                return v0;
            }
            v0 = false;
        }

        return v0;
    }

    public int hashCode() {
        return this.mimeType.hashCode() * 31 + Arrays.hashCode(this.bytes);
    }

    public String toString() {
        return "TypedByteArray[length=" + (((long) this.bytes.length)) + "]";
    }
}

